package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建一张表article
 * 表结构
 * id 整数,主键,自增
 * title 字符串,长度200
 * content 字符串,长度1000
 */
public class Test02 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection()){
            Statement statement = connection.createStatement();
            /*
                CREATE TABLE article(
                id INT PRIMARY KEY AUTO_INCREMENT,
                title VARCHAR(200),
                content VARCHAR(1000)
                );
             */
            String sql = "CREATE TABLE article(\n" +
                         "id INT PRIMARY KEY AUTO_INCREMENT,\n" +
                         "title VARCHAR(200),\n" +
                         "content VARCHAR(1000)\n" +
                         ");";
            statement.execute(sql);
            System.out.println("表格创建成功");

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
